#!/bin/sh

cd ${LXC_ROOTFS_MOUNT}/dev
mkdir -p input/ dri/ snd/ shm/

mknoddir() {
  dir=$1
  ls -l /dev/$dir* |sed 's#,# #g; s#/dev/##g;' \
    |awk '{print $1 " " $5 " " $6 " " $10}' \
    |while read perms major minor name; do
      type=$(echo $perms |sed -r 's,^(.).+$,\1,g')
      echo "mknod -m 666 $name $type $major $minor"
  done
}
mknoddir input/
mknoddir dri/
mknoddir snd/

mknod -m 666 mem c 1 1
mknod -m 666 input/event0 c 13 64
mknod -m 666 input/event1 c 13 65
mknod -m 666 input/event2 c 13 66
mknod -m 666 input/event3 c 13 67
mknod -m 666 input/event4 c 13 68
mknod -m 666 input/event5 c 13 69
mknod -m 666 input/event6 c 13 70
mknod -m 666 input/event7 c 13 71
mknod -m 666 input/mice c 13 63
mknod -m 666 input/mouse0 c 13 32
mknod -m 666 dri/card0 c 226 0
mknod -m 666 dri/controlD64 c 226 64
mknod -m 666 snd/controlC0 c 116 6
mknod -m 666 snd/controlC1 c 116 9
mknod -m 666 snd/controlD64 c 226 64
mknod -m 666 snd/midiC0D0 c 116 5
mknod -m 666 snd/midiC0D1 c 116 4
mknod -m 666 snd/midiC0D2 c 116 3
mknod -m 666 snd/midiC0D3 c 116 2
mknod -m 666 snd/pcmC1D0c c 116 8
mknod -m 666 snd/pcmC1D0p c 116 7
mknod -m 666 snd/seq c 116 1
mknod -m 666 snd/timer c 116 33

mknod -m 666 fb0 c 29 0
mknod -m 666 tty7 c 4 7
mknod -m 666 tty8 c 4 8
mknod -m 666 psaux c 10 1
mknod -m 666 hidraw0 c 248 0
mknod -m 666 hidraw1 c 248 1
mknod -m 666 vga_arbiter c 10 63
exit 0
